package org.geektimes.configuration.microprofile;

import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.spi.ConfigBuilder;

/**
 * @Author: jipeng
 * @Description:
 * @Date: Created in 2021/3/18 8:16
 */
public class ConfigMain {

    public static void main(String[] args) {
        DefaultConfigProviderResolver configProviderResolver = new DefaultConfigProviderResolver();
        ConfigBuilder configBuilder = configProviderResolver.getBuilder();

        configBuilder.addDefaultSources();
        configBuilder.addDiscoveredConverters();

        Config config = configBuilder.build();

        System.out.println(config.getPropertyNames());
        try {
            String value = config.getValue("application.name", String.class);
            System.out.println("application.name ======== " + value);

//            Integer v = config.getValue("application.name", Integer.class);
        }catch (Exception e){
            System.out.println("转换错误 msg=>" + e.getMessage());
        }

    }


}
